package com.jy.wms.common.quartz;

import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * 注册Spring-boot启动完成事件监听，用于启动job任务
 * @author liyi
 */
@Configuration
public class SchedulerListener implements ApplicationListener<ContextRefreshedEvent> {
    @Autowired
    public MyScheduler myScheduler;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) { 
        try { 
            myScheduler.scheduleJobs(); 
        } catch (SchedulerException e) {
            e.printStackTrace(); 
        }
     }
}